<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport"
    content="width=device-width, initial-scale=1, maximum-scale=1,minimum-scale=1, user-scalable=no" />
  <title>首页</title>
  <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
</head>

<body>
  <button>点击提交</button>
</body>

<script>
  let btn = document.querySelector('button')

  btn.addEventListener('click', debounce(function () {
    console.log('提交');
    console.log(this);
  }, 1000))
  function debounce(callback, delay) {
    let id = null
    return function () {
      clearTimeout(id)
      id = setTimeout(() => {
        callback.bind(this)()
      }, delay)
    }
  }


</script>

</html>